package practice;

import org.junit.Test;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class JSExecutorMethod {
	
	static  WebDriver driver;
	
	@Test
	public void shouldAbleToHandleJSMethod(){
		
	    driver = new FirefoxDriver();
		driver.manage().window().maximize();
		driver.get("http://www.toolsqa.com/automation-practice-switch-windows/");
		executeJavascript("newAlert()");
	}
	
	public static WebDriver executeJavascript(String jsscript){
		if(driver instanceof JavascriptExecutor ){
			((JavascriptExecutor)driver).executeScript(jsscript);
		}
		return driver;
	}

}
